package com.llb666.shop.gateway.client;

import com.llb666.shop.gateway.client.bo.Account;
import com.llb666.shop.gateway.client.bo.AuthResponse;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 远程调用用户服务的权限接口.
 *
 * @author llb666
 */
@FeignClient(name = "shop-user")
@Repository
public interface AuthService {

    /**
     * 登录生产token.
     *
     * @param userId 用户id
     * @return token
     */
    @PostMapping("/auth/token")
    public AuthResponse token(@RequestParam("userId") String userId);

    /**
     * 校验token.
     *
     * @param account 权限用户
     * @return AuthResponse
     */
    @PostMapping("/auth/verify")
    public AuthResponse verify(@RequestBody Account account);

    /**
     * 重新获取token.
     *
     * @param refresh 刷新token
     * @return AuthResponse
     */
    @PostMapping("/auth/refresh")
    @ResponseBody
    public AuthResponse refresh(@RequestParam("refresh") String refresh);

    /**
     * 删除token.
     *
     * @param account 权限用户
     * @return AuthResponse
     */
    @DeleteMapping("/auth/delete")
    public AuthResponse delete(@RequestBody Account account);

}
